package com.example.scribe.backend;

import com.example.scribe.SyntaxNode;
import net.bytebuddy.implementation.bytecode.StackManipulation;

/**
 * Handler interface for processing statement nodes in the AST.
 * Each handler is responsible for emitting bytecode for a specific type of statement node.
 */
public interface StatementNodeHandler {
    /**
     * Check if this handler can process the given node type.
     * 
     * @param nodeType the type of the syntax node
     * @return true if this handler can process this node type
     */
    boolean canHandle(String nodeType);

    /**
     * Process the syntax node and emit bytecode for it.
     * 
     * @param node the syntax node to process
     * @param generatedClassName the name of the generated class
     * @param locals the local variable allocator
     * @param exprEmitter the expression emitter for processing nested expressions
     * @param statementEmitter the statement emitter for processing nested statements (may be null)
     * @return StackManipulation representing the emitted bytecode, or Trivial.INSTANCE if unable to handle
     */
    StackManipulation handle(SyntaxNode node, String generatedClassName, LocalVariableAllocator locals, ExpressionEmitter exprEmitter, StatementEmitter statementEmitter);
}

